﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString = "server =.;database = teacher;uid =sa;pwd =20010616";

            SqlConnection sqlConnection = new SqlConnection(connectionString);

            sqlConnection.Open();

            var sqlCommandString = "select * from Tanle";

            SqlCommand sqlCommand = new SqlCommand(sqlCommandString, sqlConnection);

            var sqlDataReader = sqlCommand.ExecuteReader();


            while (sqlDataReader.Read())
            {
                Console.WriteLine("{0},{1},{2}", sqlDataReader["userId"], sqlDataReader["userName"], sqlDataReader["userSex"]);
            }
            sqlConnection.Close();

            Console.Read();
           
                }   
    }
}
